﻿//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Query Application Block
//===============================================================================

using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Manageability;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Manageability.Adm;
using EntLibContrib.Query.Properties;

namespace EntLibContrib.Query.Configuration.Manageability.Queries
{
	/// <summary>
	/// Represents the behavior required to provide Group Policy updates and to publish the 
	/// <see cref="ConfigurationSetting"/> instances associated to a <see cref="FileQueryData"/>.
	/// </summary>
	public abstract class FileQueryDataManageabilityProvider<T>
		: QueryDataManageabilityProvider<T>
		where T : FileQueryData
	{
		#region Constants
		/// <summary>
		/// Name for the data file property.
		/// </summary>
		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")]
		public const string DataFileKeyName = "dataFile";
		#endregion

		#region Protected Static methods
		/// <summary>
		/// Adds the part to edit the policy overrides for the custom command of a query to the content
		/// built by the <paramref name="contentBuilder"/>.
		/// </summary>
		/// <param name="contentBuilder">The builder for the content where the part will be added.</param>
		/// <param name="dataFile">The data file.</param>
		/// <param name="elementPolicyKeyName">Name of the element policy key.</param>
		protected internal static void AddDataFilePart(AdmContentBuilder contentBuilder, string dataFile, string elementPolicyKeyName)
		{
			contentBuilder.AddEditTextPart(InternalResources.FileQueryDataFilePartName,
																		elementPolicyKeyName,
																		DataFileKeyName,
																		dataFile,
																		255,
																		true);
		}
		#endregion
	}
}
